package com.glaciervirtualdevice.utils;

import lombok.Data;

/**
 * @Author: Sun
 * @DateTime: 2025/3/5 14:51
 * @Description:
 **/
@Data
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    private Result() {
    }
    public static final Integer MENU_CODE = 0;
    public static final Integer OK_CODE = 200;

    public static final String CZCG_MSG = "操作成功!";
    public static final String OK_MSG = "请求成功";
    public static final String CZ_MSG = "操作成功";
    public static final String ERR_MSG = "请求失败";
    public static final Integer ERR_CODE = 403;

    public static <T> Result<T> success() {
        Result<T> result = new Result<>();
        result.code = OK_CODE;
        result.msg = OK_MSG;
        return result;
    }
    public static <T> Result<T> CZSuccess() {
        Result<T> result = new Result<>();
        result.code = OK_CODE;
        result.msg = CZ_MSG;
        return result;
    }

    public static <T> Result<T> success(String msg) {
        Result<T> result = new Result<>();
        result.code = OK_CODE;
        result.msg = msg;
        return result;
    }

    public static <T>Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.code = OK_CODE;
        result.msg = OK_MSG;
        result.data = data;
        return result;
    }

    public static <T>Result<T> CZsuccess(T data) {
        Result<T> result = new Result<>();
        result.code = OK_CODE;
        result.msg = CZ_MSG;
        result.data = data;
        return result;
    }
    public static <T>Result<T> OK(T data) {
        Result<T> result = new Result<>();
        result.code = MENU_CODE;
        result.msg = CZCG_MSG;
        result.data = data;
        return result;
    }
    public static <T> Result<T> fail(Integer code, String msg) {
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = msg;
        return result;
    }
    public static <T> Result<T> err() {
        Result<T> result = new Result<>();
        result.code = ERR_CODE;
        result.msg = ERR_MSG;
        return result;
    }
    public static <T> Result<T> err(String msg) {
        Result<T> result = new Result<>();
        result.code = ERR_CODE;
        result.msg = msg;
        return result;
    }
    public static <T>Result<T> err(T data) {
        Result<T> result = new Result<>();
        result.code = ERR_CODE;
        result.msg = ERR_MSG;
        result.data = data;
        return result;
    }

    public static <T> Result<T> err(Integer code, String msg) {
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = msg;
        return result;
    }

    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<>();
        result.code = 500;
        result.msg = message;
        return result;
    }

    public static <T> Result<T> error(Integer code, String message) {
        Result<T> result = new Result<>();
        result.code = code;
        result.msg = message;
        return result;
    }
}
